package com.itheima.homework.迭代器;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo1 {
    public static void main(String[] args) {
        Collection<String> c=new ArrayList<>();
        c.add("JavaEE企业级开发指南");
        c.add("Oracle高级编程");
        c.add("MySQL从入门到精通");
        c.add("Java架构师之路");
        Iterator<String> iterator = c.iterator();
        //test1(iterator);
        //test2(iterator);
        test3(iterator);
    }

    public static void test3(Iterator<String> iterator) {
        while (iterator.hasNext()){
            String next = iterator.next();
            if(next.contains("Java")){
                System.out.println(next);
            }
        }
    }

    public static void test2(Iterator<String> iterator) {
        while (iterator.hasNext()){
            String next = iterator.next();
            if(next.length()<10){
                System.out.println(next);
            }
        }
    }

    public static void test1(Iterator<String> iterator) {
        while (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }
    }
}
